home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb1.arc
/
G_INPUT.INC
< prev
next >
Wrap
Text File
|
1986-03-04
|
49KB
|
1,203 lines
{ G_INPUT.INC }
{ *************************************************************************** }
{ * * }
{ * TURBO SCREEN INPUT PRE-PROCESSOR TOOLKIT * }
{ * * }
{ * GENERAL INPUT SUBPROGRAM INCLUDE FILE * }
{ * * }
{ * Version 1.07 * }
{ * * }
{ * * }
{ * This file contains all the modules necessary for your use of the * }
{ * input pre-processor to support as many general input pages as your * }
{ * application program requires. * }
{ * * }
{ * Note that further documentation on general input page support can * }
{ * be found in the documentation file 'Tsipp.Doc'. * }
{ * * }
{ *************************************************************************** }
Const { General Input Page Data Structure Constants }
G_I_RECORD_LIMIT=40; { maximum number of entries allowed in any given }
{ general input page }
MAX_SIZE_OF_G_I_PROMPT=50; { size of general input prompt string }
MAX_SIZE_OF_G_I_ENTRY=40; { size of input data entry string }
Type { General Input Page Data Structure }
G_I_RecordPtr=^G_I_Record; { pointer to a general input page template record }
{ which is stored in the heap }
G_I_Record= { record type used for general input page templates }
Record { used to store specific information about a particular }
PromptCol, { general input page prompt }
PromptRow,
InputCol,
InputRow,
InputLength,
InputDataType,
ReturnKeyPointer,
UpKeyPointer,
DownKeyPointer,
LeftKeyPointer,
RightKeyPointer:Integer;
Prompt:String[MAX_SIZE_OF_G_I_PROMPT];
End; { G_I_Record }
Typical_G_I_Page= { a record data type which stores }
Record { for each general input page: }
Image:TextScreenPtr; { a general input page screen image }
Template:Array[1..G_I_RECORD_LIMIT] Of G_I_RecordPtr; { a general input page screen template }
End; { Typical_G_I_Page }
G_I_DataEntryPtr=^G_I_DataEntry; { pointer to an input data string entry }
G_I_DataEntry=String[MAX_SIZE_OF_G_I_ENTRY]; { data string type used for storing input data entries }
Var { General Input Page Data Structure Variables }
G_I_Pages: { an array constructed of the data type Typical }
Array[1..MAX_NUM_OF_G_I_PAGES] Of Typical_G_I_Page; { general input page }
G_I_Data: { two dimensional array for storing input data from }
Array[1..G_I_RECORD_LIMIT,1..MAX_NUM_OF_G_I_PAGES] Of G_I_DataEntryPtr; { the general input pages }
{ miscellaneous variables for the example application of the input pre-processor }
NewFile:Boolean; { a boolean flag used in detecting if the current }
{ listed input file name is a newly created file }
BeamLength:Real; { variable use to store converted beam length }
Procedure Read_G_I_Files;
{ This procedure reads the general input screen page images and templates and
stores them into the proper G_I_Pages[G_I_Page] record. Note that G_I_Page
screen page images are stored under the file names 'G_I_##.Col(or Mon)',
where ## refers to the G_I_Page number, 'Col' refers to a color screen
page, and 'Mon' refers to a monochrome screen page. Note that G_I_Page
templates are stored under the file names 'G_I_##.@@@', where ## refers to
the general input page number and '@@@' refers to template file extension
constant previously defined in the file 'Main.Mod'.
Note that the template records are pointed to by the template array (an
array of pointers) and if there are not enough records from the template
file to fill the template array of pointers for a particular G_I_Page,
those empty array pointers are set to Nil. }
Var
G_I_Page:Integer; { an index to a particular general input page }
RecordNumber:Integer; { an index to a particular general input template record }
Page:String[2]; { a string used in determining the current G_I_Page file number }
G_I_TemplateFile:File Of G_I_Record; { G_I_Page file template type }
Begin { Read_G_I_Files }
For G_I_Page:=1 To MAX_NUM_OF_G_I_PAGES Do
With G_I_Pages[G_I_Page] Do
Begin
{ determine file number portion of G_I_Page file name }
Str(G_I_Page,Page); { convert integer file number into a string }
If G_I_Page<=9 Then
Page:='0'+Page;
{ initializing screen page pointer }
Image:=Nil;
{ read G_I_Page screen image }
ReadScreenPageFromFile('G_I_'+Page,Image);
{ read G_I_Page template }
Assign(G_I_TemplateFile,'G_I_'+Page+TEMPLATE_FILE_NAME_EXTENSION); { assign to a disk file }
Reset(G_I_TemplateFile); { open the file for reading }
For RecordNumber:=1 To G_I_RECORD_LIMIT Do
If Not Eof(G_I_TemplateFile) Then
Begin
New(Template[RecordNumber]); { allocate space in heap for template record }
Read(G_I_TemplateFile,Template[RecordNumber]^); { read record off of disk }
End { If Not Eof }
Else
Template[RecordNumber]:=Nil; { no record to read, set pointer in template array to Nil }
Close(G_I_TemplateFile); { close the file }
End; { With G_I_Pages[G_I_Page] }
End; { Read_G_I_Files }
Procedure Init_G_I_DataEntries;
{ This procedure initializes the general input page input data array. Note
that the pointers of the data array that don't correspond to any data
entry on a particular G_I_Page are set to Nil. }
Var
Page:Integer; { an index to a particular G_I_Page }
Entry:Integer; { an index to a particular G_I_Page record }
Begin { Init_G_I_DataEntries }
For Page:=1 To MAX_NUM_OF_G_I_PAGES Do
For Entry:=1 To G_I_RECORD_LIMIT Do
If G_I_Pages[Page].Template[Entry]=Nil Then
G_I_Data[Entry,Page]:=Nil { no corresponding prompt entry in template }
Else
Begin
New(G_I_Data[Entry,Page]); { allocate space in heap for input data }
G_I_Data[Entry,Page]^:=''; { corresponding data entry in template }
End; { Else }
End; { Init_G_I_DataEntries }
Procedure DisposeOf_G_I_DynamicMemory;
{ This procedure releases all the dynamically allocated memory used in the
general input pages back to the operating system. }
Var
G_I_Page:Integer; { an index to a particular G_I_Page }
Entry:Integer; { an index to a particular G_I_Page template entry }
Begin { DisposeOf_G_I_DynamicMemory }
For G_I_Page:=1 To MAX_NUM_OF_G_I_PAGES Do
Begin
Dispose(G_I_Pages[G_I_Page].Image); { dispose screen page image }
For Entry:=1 To G_I_RECORD_LIMIT Do
If G_I_Pages[G_I_Page].Template[Entry]<>Nil Then
Begin
Dispose(G_I_Pages[G_I_Page].Template[Entry]); { dispose of template entry }
Dispose(G_I_Data[Entry,G_I_Page]); { dispose of data entry }
End; { If G_I_Pages }
End; { For G_I_Page }
End; { DisposeOf_G_I_DynamicMemory }
Procedure Write_G_I_Entries;
{ This procedure locates and prints on the screen the input entries for the
current general input page. This procedure looks at the G_I_Page template to
determine the required information for locating and printing out each
G_I_Page input entry. }
Var
Index:Integer; { index counter used in listing out the G_I prompts and data entries }
Col:Integer; { column index counter used in erasing old input data entries }
TextString:WorkString; { temporary string used in clearing out an old entry }
Begin { Write_G_I_Entries }
TextColor(ForegroundColor);
TextBackground(BackgroundColor);
Window(1,1,80,25); { reset the active window }
Index:=1; { initialize counter }
While G_I_Pages[G_I_Page].Template[Index]<>Nil Do { check that there is a valid prompt listing }
Begin { print out data entry }
With G_I_Pages[G_I_Page].Template[Index]^ Do
Begin
{ this routine removes old input data entry }
TextString:=''; { initialize to nul string }
For Col:=1 To InputLength Do { build blank string }
TextString:=TextString+' ';
SpeedPrint(TextString,InputCol,InputRow);
{ write out data entry }
TextString:=G_I_Data[Index,G_I_Page]^; { convert data string into a WorkString }
SpeedPrint(TextString,InputCol,InputRow);
End; { With G_I_Pages }
Index:=Index+1; { increment counter }
End; { While G_I_Pages }
End; { Write_G_I_Entries }
Procedure HighlightSpecial_G_I_Prompts;
{ This procedure highlights the special quick input keystroke characters for
specific G_I_Page prompts. Note that the case statement below only supports
4 general input pages, but can easily be added to inorder to support
additional pages. }
Begin { HighlightSpecial_G_I_Prompts }
TextColor(QuickInputHighlightColor);
TextBackground(BackgroundColor);
Case G_I_Page Of
1 : Begin
GotoXY(21,9);
Write('U');
GotoXY(21,10);
Write('U');
GotoXY(33,13);
Write('PA');
GotoXY(42,13);
Write('PE');
GotoXY(28,14);
Write('I');
GotoXY(37,14);
Write('E');
GotoXY(29,15);
Write('S');
GotoXY(36,15);
Write('U');
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
End; { HighlightSpecial_G_I_Prompts }
Procedure Show_G_I_EmptyEntry( Descriptor:Integer);
{ This procedure prints out the proper sized reversed video input block
at the passed descriptor prompt (prompt that the cursor is located at) to
show an empty input data entry. }
Var
Col:Integer; { column index counter used in displaying empty input data entry }
Begin { Show_G_I_EmptyEntry }
TextColor(BlockForegroundColor);
TextBackground(BlockBackgroundColor);
With G_I_Pages[G_I_Page].Template[Descriptor]^ Do
Begin
GotoXY(InputCol,InputRow);
For Col:=1 To InputLength Do
Write(' ');
GotoXY(InputCol,InputRow);
End; { With G_I_Pages }
End; { Show_G_I_EmptyEntry }
Procedure Show_G_I_CharEntry( LegalChar:Char);
{ This procedure prints the passed legal character entry at wherever the cursor
happens to be positioned at. }
Begin { Show_G_I_CharEntry }
TextColor(CharacterInputColor);
TextBackground(BackgroundColor);
Write(LegalChar);
End; { Show_G_I_CharEntry }
Procedure Move_G_I_InputPromptBlockModule( OldPrompt,
NewPrompt:Integer);
{ *************************************************************************** }
{ * * }
{ * MOVE GENERAL INPUT PAGE INPUT PROMPT BLOCK MODULE * }
{ * * }
{ * This module controls the movement of the highlighted prompt and * }
{ * input block for the passed old and new prompt entry number for the * }
{ * current general input page. * }
{ * * }
{ *************************************************************************** }
Procedure ShowInputPrompt( Descriptor,
PromptColor,
PromptBackground,
InputBlockColor,
InputBlockBackground:Integer);
{ This procedure is used exclusively to highlight the current input prompt
and input block and also to de-highlight the previous input prompt and
input block. }
Var
Col:Integer; { column index counter used in displaying an empty input data entry }
Begin { ShowInputPrompt }
With G_I_Pages[G_I_Page].Template[Descriptor]^ do
Begin
{ re-write prompt in passed screen colors }
TextColor(PromptColor);
TextBackground(PromptBackground);
GotoXY(PromptCol,PromptRow);
Write(Prompt);
{ clear input data entry }
GotoXY(InputCol,InputRow);
For Col:=1 To InputLength Do
Write(' ');
{ re-write input data entry in passed screen colors }
TextColor(InputBlockColor);
TextBackground(InputBlockBackground);
GotoXY(InputCol,InputRow);
If Length(G_I_Data[Descriptor,G_I_Page]^)=0 Then
For Col:=1 To InputLength Do { write out empty entry ( reversed video input block) }
Write(' ')
Else { write out input entry }
Write(G_I_Data[Descriptor,G_I_Page]^);
End; { With G_I_Pages }
End; { ShowInputPrompt }
Begin { Move_G_I_InputPromptBlockModule }
ShowInputPrompt(OldPrompt, { de-highlight old input prompt and input data entry }
ForegroundColor,
BackgroundColor,
ForegroundColor,
BackgroundColor);
ShowInputPrompt(NewPrompt, { highlight new input prompt and input data entry }
HighlightColor,
BackgroundColor,
BlockForegroundColor,
BlockBackgroundColor);
HighlightSpecial_G_I_Prompts;
End; { Move_G_I_InputPromptBlockModule }
Procedure Draw_G_I_PagesModule;
{ *************************************************************************** }
{ * * }
{ * DRAW GENERAL INPUT PAGES MODULE * }
{ * * }
{ * This module controls the display of particular general input pages. * }
{ * Note that the case statement below only supports 4 general input * }
{ * pages, but this can easily be added to inorder for this module to * }
{ * support additional general input pages. * }
{ * * }
{ * Note that within this module there is an example procedure that * }
{ * was used during program development to construct a screen page. * }
{ * Later, the screen pages are read from screen files and stored in the * }
{ * heap for more rapid display. * }
{ * * }
{ *************************************************************************** }
Procedure Write_G_I_Prompts;
{ This procedure locates and prints on the screen the prompts for the current
general input page. This procedure looks at the G_I_Page template to
determine the required information for locating and printing out each
G_I_Page prompt. }
Var
Index:Integer; { index counter used in listing out the G_I prompts }
Begin { Write_G_I_Prompts }
TextColor(ForegroundColor);
TextBackground(BackgroundColor);
Index:=1; { initialize counter }
While G_I_Pages[G_I_Page].Template[Index]<>Nil Do { check that there is a valid prompt listing }
Begin { print out G_I prompt }
With G_I_Pages[G_I_Page].Template[Index]^ Do
Begin
GotoXY(PromptCol,PromptRow);
SpeedWrite(Prompt);
End; { With G_I_Pages }
Index:=Index+1; { increment counter }
End; { While G_I_Pages }
End; { Write_G_I_Prompts }
Procedure Draw_G_I_Page01;
{ This part of the procedure was used during program development to
construct a screen page. This screen page is now stored in a screen file
and thus the application program does not really need this code any longer.
The screen page is read from a file and stored in the heap for rapid
display.
You may want to write a similar procedure during your application program
development. }
Var
TextString:WorkString; { string variable used in passing text to another procedure }
Begin { Draw_G_I_Page01 }
TextColor(ForegroundColor);
TextBackground(BackgroundColor);
DrawWindow2(1,1,80,25); { place border along edge of screen }
{ place title on top of screen }
TextColor(HighlightColor);
WriteCenterText(1,'GENERAL INPUT DATA');
{ place menu on bottom portion of screen pertaining to proper page }
TextColor(ForegroundColor);
TextString:='Home(Directory) PgDn '+Chr(27)+' '+Chr(26)+' '+Chr(24)+' '+Chr(25)+' Del Esc';
WriteCenterText(25,TextString);
DrawHorizWindowLine2(1,12,80);
DrawHorizWindowLine2(1,16,80);
Write_G_I_Prompts;
HighlightSpecial_G_I_Prompts;
(* WriteScreenPageToFile('G_I_01'); { write the screen page off to a screen file } *)
End; { Draw_G_I_Page01 }
Begin { Draw_G_I_PagesModule }
Case G_I_Page Of
1 : Begin
(* Draw_G_I_Page01; { this line was used during program development } *)
DisplayScreenPage(G_I_Pages[G_I_Page].Image); { display screen page that is stored in the heap }
{ specific routine for example application of the input pre-processor }
If NewFile Then
LabelNewFile; { label user defined input data file as new file }
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
Write_G_I_Entries;
Move_G_I_InputPromptBlockModule(1,1);
End; { Draw_G_I_PagesModule }
Procedure Check_G_I_CharEntryModule( Descriptor :Integer;
Var AccumDataEntry:WorkString;
CharEntry :Char);
{ *************************************************************************** }
{ * * }
{ * CHECK GENERAL INPUT PAGE CHARACTER INPUT ENTRY MODULE * }
{ * * }
{ * This module checks the passed CharEntry character by checking to see * }
{ * that it is a legal character for the passed Descriptor (or current * }
{ * prompt). If CharEntry is legal then this module adds the CharEntry * }
{ * to the passed AccumDataEntry (accumulated data entry string). If * }
{ * CharEntry is not legal then this module ignores the passed character * }
{ * and sounds an error to identify that the user has keystroked in an * }
{ * illegal character. * }
{ * * }
{ * This module begins by first checking to see if the accumulated data * }
{ * entry length is less than the maximum allowed length. Finally the * }
{ * module checks that to see if the single character that has been * }
{ * entered is of the type allowed. * }
{ * * }
{ * A list of different input data types this module can check for * }
{ * follows: * }
{ * * }
{ * Input * }
{ * Data * }
{ * Type * }
{ * Value Description of Input Data Type * }
{ * ----- ----------------------------------------- * }
{ * 1 Positive Integer ( including zero ) * }
{ * 2 Negative Integer ( including zero ) * }
{ * 3 Integer * }
{ * 4 Positive Real ( including zero ) * }
{ * 5 Negative Real ( including zero ) * }
{ * 6 Real * }
{ * 7 Data File Name * }
{ * 8 Disk Drive Subdirectory Path * }
{ * 9 General * }
{ * * }
{ *************************************************************************** }
Type
CharSet=Set Of Char; { a set of legal characters used for checking the character entry }
Var
LegalCharSet:CharSet; { a variable used for storing a set of legal characters }
Procedure DetermineLegalCharSet( DataType :Integer;
DataEntry :WorkString;
Var LegalCharSet:CharSet);
{ This procedure determines the legal set of characters for the current data
entry by looking at the passed DataType value. }
Var
DecimalOccurrence:Boolean; { boolean used to test for the occurence of a decimal point in the passed string }
Begin { DetermineLegalCharSet }
DecimalOccurrence:=(Pos('.',DataEntry)<>0); { If true then decimal point is contained within data entry }
Case DataType Of
1 : Begin { Positive Integer }
LegalCharSet:=['0'..'9'];
End; { Positive Integer }
2 : Begin { Negative Integer }
If Length(DataEntry)=0 Then
LegalCharSet:=['-']
Else
LegalCharSet:=['0'..'9'];
End; { Negative Integer }
3 : Begin { Integer }
If Length(DataEntry)=0 Then
LegalCharSet:=['-','0'..'9']
Else
LegalCharSet:=['0'..'9'];
End; { Integer }
4 : Begin { Positive Real }
If DecimalOccurrence Then
LegalCharSet:=['0'..'9']
Else
LegalCharSet:=['.','0'..'9'];
End; { Positive Real }
5 : Begin { Negative Real }
If Length(DataEntry)=0 Then
LegalCharSet:=['-']
Else
If DecimalOccurrence Then
LegalCharSet:=['0'..'9']
Else
LegalCharSet:=['.','0'..'9'];
End; { Negative Real }
6 : Begin { Real }
If Length(DataEntry)=0 Then
LegalCharSet:=['-','.','0'..'9']
Else
If DecimalOccurrence Then
LegalCharSet:=['0'..'9']
Else
LegalCharSet:=['.','0'..'9'];
End; { Real }
7 : Begin { Data File Name }
LegalCharSet:=['A'..'Z','a'..'z','0'..'9','_','-','!','@','#','$',
'%','&'];
End; { Data File Name }
8 : Begin { Disk Drive Subdirectory Path }
LegalCharSet:=['A'..'Z','a'..'z','0'..'9','_','-','!','@','#','$',
'%','&','\',':'];
End; { Disk Drive Subdirectory Path }
9 : Begin { General }
LegalCharSet:=['A'..'Z','a'..'z','0'..'9','`','~','!','@','#','$',
'%','^','&','*','(',')','-','_','=','+','\','|','[',
'{',']','}',';',':','"',',','<','.','>','/','?',' '];
End; { General }
End; { Case DataType }
End; { DetermineLegalCharSet }
Begin { Check_G_I_CharEntryModule }
With G_I_Pages[G_I_Page].Template[Descriptor]^ Do
Begin
If Length(AccumDataEntry)<InputLength Then { check length of accumulated data entry }
Begin
DetermineLegalCharSet(InputDataType,AccumDataEntry,LegalCharSet);
If CharEntry In LegalCharSet Then
Begin { legal character entry, add to accumulated data entry }
AccumDataEntry:=AccumDataEntry+CharEntry;
If Length(AccumDataEntry)=1 Then
Show_G_I_EmptyEntry(Descriptor);
Show_G_I_CharEntry(CharEntry);
End { If CharEntry }
Else { illegal character entry }
SoundError;
End { If Length(accumDataEntry) }
Else { allowable length of accumulated character entry has been reached, no more entry of characters allowed }
SoundError;
End; { With G_I_Pages }
End; { Check_G_I_CharEntryModule }
Procedure Special_G_I_CharEntryModule(Var OldPrompt,
NewPrompt:Integer;
CharEntry:Char);
{ *************************************************************************** }
{ * * }
{ * SPECIAL GENERAL INPUT PAGE CHARACTER ENTRY MODULE * }
{ * * }
{ * There may be specific input data entries that have been defined to * }
{ * have 2, 3, or more special characters as input. This module checks * }
{ * for the entry of these special characters. * }
{ * * }
{ * Note that the case statement below only supports 4 general input * }
{ * pages, but this can easily be added to inorder for this module to * }
{ * support additional general input pages. * }
{ * * }
{ * Note that the procedures within this module have been written * }
{ * specifically for the example application of the input pre-processor. * }
{ * You may want to write similar procedures for your application. * }
{ * * }
{ *************************************************************************** }
Procedure DeckOrientation( CharEntry:Char);
{ This procedure controls the selection of deck orientation. Note that
the special characters defined for this entry are:
'PA' = PARALLEL
'PE' = PERPENDICULAR }
Begin { DeckOrientation }
If Not(CharEntry In ['P','p']) Then
SoundError { illegal character entry }
Else
Begin
CharEntry:='P';
With G_I_Pages[G_I_Page].Template[NewPrompt]^ Do
GotoXY(InputCol,InputRow);
Show_G_I_CharEntry(CharEntry);
Repeat
Read(Kbd,CharEntry);
If Not(CharEntry In ['A','a','E','e']) Then
SoundError; { illegal entry }
Until CharEntry In ['A','a','E','e'];
If CharEntry In ['A','a'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='PARALLEL';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else
If CharEntry In ['E','e'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='PERPENDICULAR';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else { illegal character entry }
SoundError;
End; { Else }
End; { DeckOrientation }
Procedure MemberType( CharEntry:Char);
{ This procedure controls the selection of beam member type. Note that
the special characters defined for this entry are:
'I' = INTERIOR
'E' = EDGE }
Begin { MemberType }
If CharEntry In ['I','i'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='INTERIOR';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else
If CharEntry In ['E','e'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='EDGE';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else { illegal character entry }
SoundError;
End; { MemberType }
Procedure Construction( CharEntry:Char);
{ This procedure controls the selection of construction type. Note that
the special characters defined for this entry are:
'S' = SHORED
'U' = UNSHORED }
Begin { Construction }
If CharEntry In ['S','s'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='SHORED';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else
If CharEntry In ['U','u'] Then
Begin
G_I_Data[NewPrompt,G_I_Page]^:='UNSHORED';
OldPrompt:=NewPrompt;
NewPrompt:=G_I_Pages[G_I_Page].Template[NewPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,NewPrompt);
End { If CharEntry }
Else { illegal character entry }
SoundError;
End; { Construction }
Begin { Special_G_I_CharEntryModule }
Case G_I_Page Of
1 : Begin
Case NewPrompt Of
10 : DeckOrientation(CharEntry);
11 : MemberType(CharEntry);
12 : Construction(CharEntry);
End; { Case NewPrompt }
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
End; { Special_G_I_CharEntryModule }
Procedure G_I_EntryModule;
{ *************************************************************************** }
{ * * }
{ * GENERAL INPUT PAGE ENTRY MODULE * }
{ * * }
{ * This module takes care of the display and user interaction with * }
{ * the program's general input pages. This general input page module * }
{ * uses templates in controlling the interaction between the user and * }
{ * the displayed general input page. * }
{ * * }
{ * A template is simply a file containing information about the * }
{ * prompts (or descriptors) to be displayed when a particular G_I_Page * }
{ * is shown. A G_I_Page template is a series of records where each * }
{ * record describes one prompt and data entry field in that G_I_Page. * }
{ * For more information on templates see the toolkit documentation * }
{ * file 'TOOLKIT.DOC'. * }
{ * * }
{ *************************************************************************** }
Var
OldPrompt:Integer; { an index to the previously highlighted input prompt }
CurrentPrompt:Integer; { an index to the current highlighted input prompt }
ExitModule:Boolean; { a flag used in determining when to exit this input module }
Procedure Init_G_I_Variables;
{ This procedure initializes the G_I_Page module's variables. }
Begin { Init_G_I_Variables }
OldPrompt:=2;
CurrentPrompt:=1;
ExitModule:=False;
End; { Init_G_I_Variables }
Procedure Escape;
{ This procedure controls the entry of a escape command. Note that the case
statement below only supports 4 general input pages, but this can easily be
added to inorder to support additional general input pages. Note that upon
issuing the escape command, the user is signaling that he wants to exit the
input pre-processor. Before exiting the pre-processor the user is queried
to see if he wants to save his data. }
Begin { Escape }
Case G_I_Page Of
1 : Begin
WriteInputFileModule(ExitModule); { if passed boolean returns true, then exit this module }
If ExitModule Then
Begin { return to MainModule and then to first menu page }
MenuPage:=1;
CurrentPage:=Menu;
End; { If ExitModule }
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
End; { Escape }
Procedure PageUp;
{ This procedure controls the entry of a page up command. Note that the case
statement below only supports 4 general input pages, but can easily be
added to inorder to support additional general input pages. }
Begin { PageUp }
Case G_I_Page Of
1 : Begin
SoundError;
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
End; { PageUp }
Procedure PageDown;
{ This procedure controls the entry of a page down command. Note that the
case statement below only supports 4 general input pages, but this can
easily be added to inorder to support additional general input pages. }
Var
CharEntry:WorkString; { character variable used in passing a dummy character entry to another procedure }
Begin { PageDown }
Case G_I_Page Of
1 : Begin
{ specific to example application of input pre-processor }
If G_I_Data[13,G_I_Page]^='' Then { beam span must be entered before allowing user to page downward }
Begin
CharEntry:=Chr(81); { send dummy character value (=PageDown Key) }
G_I_ErrorCheckingModule(OldPrompt,CurrentPrompt,CharEntry);
End { If G_I_Data }
Else { exit this module and go to requested page }
Begin
G_I_Page:=1;
S_I_Page:=1;
CurrentPage:=S_I; { pass control to S_I_InputModule }
ExitModule:=True;
End; { Else }
End; { page 1 }
2 : Begin
End; { page 2 }
3 : Begin
End; { page 3 }
4 : Begin
End; { page 4 }
End; { Case G_I_Page }
End; { PageDown }
Procedure CurseUp;
{ This procedure controls the cursor's upward movement in the current general
input page. It checks the G_I_Page template to see if the requested cursor
move is allowable for the current G_I_Page. }
Begin { CurseUp }
With G_I_Pages[G_I_Page].Template[CurrentPrompt]^ do
Begin
If UpKeyPointer<>0 Then
Begin { legal move }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=UpKeyPointer;
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If UpKeyPointer }
Else { not a legal move }
SoundError;
End; { With G_I_Pages }
End; { CurseUp }
Procedure CurseDown;
{ This procedure controls the cursor's downward movement in the current
general input page. It checks the G_I_Page template to see if the
requested cursor move is allowable for the current G_I_Page. }
Begin { CurseDown }
With G_I_Pages[G_I_Page].Template[CurrentPrompt]^ Do
Begin
If DownKeyPointer<>0 Then
Begin { legal move }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=DownKeyPointer;
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If DownKeyPointer }
Else { not a legal move }
SoundError;
End; { With G_I_Pages }
End; { CurseDown }
Procedure CurseLeft;
{ This procedure controls the cursor's leftward movement in the current
general input page. It checks the G_I_Page template to see if the
requested cursor move is allowable for the current G_I_Page. }
Begin { CurseLeft }
With G_I_Pages[G_I_Page].Template[CurrentPrompt]^ Do
Begin
If LeftKeyPointer<>0 Then
Begin { legal move }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=LeftKeyPointer;
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If LeftKeyPointer }
Else { not a legal move }
SoundError;
End; { With G_I_Pages }
End; { CurseLeft }
Procedure CurseRight;
{ This procedure controls the cursor's rightward movement in the current
general input page. It checks the G_I_Page template to see if the
requested cursor move is allowable for the current G_I_Page. }
Begin { CurseRight }
With G_I_Pages[G_I_Page].Template[CurrentPrompt]^ Do
Begin
If RightKeyPointer<>0 Then
Begin { legal move }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=RightKeyPointer;
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If RightKeyPointer }
Else { not a legal move }
SoundError;
End; { With G_I_Pages }
End; { CurseRight }
Procedure DeleteEntry;
{ This procedure controls the deletion of an entry for the current general
input page. }
Begin { DeleteEntry }
G_I_Data[CurrentPrompt,G_I_Page]^:='';
OldPrompt:=CurrentPrompt;
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
{ following routine is specific to the example application of the input pre-processor }
If (CurrentPrompt=1) And (G_I_Page=1) Then
RemoveNewFileLabel; { remove label describing user named input data file as a new file }
End; { DeleteEntry }
Procedure Backspace(Var AccumCharEntry:Workstring);
{ This procedure removes the last character in the passed accumulated
character entry for the current general input page. }
Var
CharEntry:Char; { character variable used in printing out the now shortened string }
Col:Integer; { column index counter used in printing out the now shortened input data entry }
Begin { Backspace }
If Length(AccumCharEntry)<>0 Then
Begin
Delete(AccumCharEntry,Length(AccumCharEntry),1); { remove last character in accumulated string entry }
Show_G_I_EmptyEntry(CurrentPrompt); { rewrite over old entry with empty input block }
For Col:=1 To Length(AccumCharEntry) Do
Begin { re-display newly shortened accumulated string entry }
CharEntry:=Copy(AccumCharEntry,Col,1);
Show_G_I_CharEntry(CharEntry);
End; { For Col }
End { If Length }
Else { not able to remove any more characters from empty input data entry }
SoundError;
End; { Backspace }
Procedure CarriageReturn;
{ This procedure accepts the user's carriage return entry and in response
moves the reversed video input block to the next defined input prompt.
This procedure uses The G_I_Page template for the current G_I_Page to
determine the next prompt it should move to. }
Begin { CarriageReturn }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=G_I_Pages[G_I_Page].Template[CurrentPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End; { CarriageReturn }
Procedure AccumulateEntry( CharEntry:Char);Forward;
Procedure UpgradeDate( CharEntry:Char);
{ This procedure controls the upgrading of the date entry to the computer's
clock date by making a call to DOS or by allowing the user to enter his
own date. }
Begin { UpgradeDate }
If CharEntry In ['U','u'] Then
Begin { user requesting system date }
G_I_Data[CurrentPrompt,G_I_Page]^:=Date1;
OldPrompt:=CurrentPrompt;
CurrentPrompt:=G_I_Pages[G_I_Page].Template[CurrentPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If CharEntry }
Else { user entering his own date }
AccumulateEntry(CharEntry);
End; { UpgradeDate }
Procedure UpgradeTime( CharEntry:Char);
{ This procedure controls the upgrading of the time entry to the computer's
clock time by making a call to DOS or by allowing the user to enter his
own time. }
Begin { UpgradeTime }
If CharEntry In ['U','u'] Then
Begin { user requesting system time }
G_I_Data[CurrentPrompt,G_I_Page]^:=Time;
OldPrompt:=CurrentPrompt;
CurrentPrompt:=G_I_Pages[G_I_Page].Template[CurrentPrompt]^.ReturnKeyPointer; { determine next record to move to }
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End { If CharEntry }
Else { user entering his own time }
AccumulateEntry(CharEntry);
End; { UpgradeTime }
Procedure AccumulateEntry;{( CharEntry:Char)}
{ This procedure controls the accumulation of inputed characters for a data
entry for the current general input page. Note that the call to
Check_G_I_CharEntryModule checks to see if the CharEntry is legal, and if
so then places the legal character into the AccumCharEntry. }
Var
AccumCharEntry:WorkString; { string variable used to store the accumulated keyboard entry }
MaxEntryLength:Integer; { variable used to store maximum allowable data input entry length }
Begin { AccumulateEntry }
AccumCharEntry:=''; { initialize accumulated keyboard entry }
With G_I_Pages[G_I_Page].Template[CurrentPrompt]^ Do
GotoXY(InputCol,InputRow); { locate at start of the data entry }
ShowBlinkingCursor;
Check_G_I_CharEntryModule(CurrentPrompt,AccumCharEntry,CharEntry);
Repeat
Read(Kbd,CharEntry);
If (CharEntry=Chr(27)) And KeyPressed Then { Read illegal double character entry without executing code command. }
Begin
Read(Kbd,CharEntry);
SoundError;
End { If CharEntry }
Else
If CharEntry=Chr(8) Then { backspace }
Backspace(AccumCharEntry)
Else
If CharEntry<>Chr(13) Then { carriage return }
Check_G_I_CharEntryModule(CurrentPrompt,AccumCharEntry,CharEntry);
Until CharEntry=Chr(13); { carriage Return }
HideBlinkingCursor;
If (AccumCharEntry='.') Or (AccumCharEntry='-') Or (AccumCharEntry='-.') Then
AccumCharEntry:=''; { remove meaningless entry }
G_I_ErrorCheckingModule(OldPrompt,CurrentPrompt,AccumCharEntry);
G_I_Data[CurrentPrompt,G_I_Page]^:=AccumCharEntry; { transfer accumulated data entry into data structure }
OldPrompt:=CurrentPrompt;
CurrentPrompt:=G_I_Pages[G_I_Page].Template[CurrentPrompt]^.ReturnKeyPointer; { determine next record to move to }
{ following routine is specific to the example application of the input pre-processor }
If ((OldPrompt=1) Or (OldPrompt=2)) And (G_I_Page=1) Then
ReadInputFileModule; { pass control temporarily to ReadInputFileModule }
Move_G_I_InputPromptBlockModule(OldPrompt,CurrentPrompt);
End; { AccumulateEntry }
Procedure ReadKeyboard;
{ This procedure determines what the user's keyboard entry is. It passes
control to specific procedures within this module if a screen command
dealing with the general input page is called upon. }
Var
KeyboardEntry:Char; { variable used in storing the character read from the keyboard }
Begin
Read(Kbd,KeyboardEntry);
If (KeyboardEntry=Chr(27)) And KeyPressed Then { read a character, check for a double character entry }
Begin { double character entry }
Read(Kbd,KeyboardEntry);
Case Ord(KeyboardEntry) Of
73 : PageUp;
81 : PageDown;
72 : CurseUp;
80 : CurseDown;
75 : CurseLeft;
77 : CurseRight;
83 : DeleteEntry;
71 : DirectoryModule;
Else { illegal keystroke }
SoundError;
End; { Case Ord(KeyboardEntry) }
End { If KeyboardEntry }
Else
Begin { single character entry }
Case Ord(KeyboardEntry) Of
13 : CarriageReturn;
27 : Escape;
Else
Begin { check for special character entry }
Case CurrentPrompt Of
7 : UpgradeDate(KeyboardEntry);
8 : UpgradeTime(KeyboardEntry);
10 : Special_G_I_CharEntryModule(OldPrompt,CurrentPrompt,KeyboardEntry);
11 : Special_G_I_CharEntryModule(OldPrompt,CurrentPrompt,KeyboardEntry);
12 : Special_G_I_CharEntryModule(OldPrompt,CurrentPrompt,KeyboardEntry);
Else { accumulate data entry from user }
AccumulateEntry(KeyboardEntry);
End; { Case CurrentPrompt }
End; { Else }
End; { Case Ord(KeyboardEntry) }
End; { Else }
End; { ReadKeyboard }
Begin { G_I_P_EntryModule }
Init_G_I_Variables;
Draw_G_I_PagesModule;
Repeat
ReadKeyboard;
Until ExitModule;
End; { G_I_P_EntryModule }